<!DOCTYPE html>
<!-- templates -->
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Cloud Recording</title>
  <script src="./edu_sdk.bundle.js"></script>
</head>

<body>
  <style>
    #root1 {
      width: 100%;
      height: 100%;
    }
  </style>
  <div id="root1"></div>
  <script type="text/javascript">

  function useParams (location) {
    const searchString = location.href.split('?').pop()
    const urlParams = new URLSearchParams(location.href.split('?').pop())
    const audienceParams = {}
    for (let key of urlParams.keys()) {
      audienceParams[key] = urlParams.get(key)
    }
    console.log("urlParams ", audienceParams)
    return audienceParams
  }

  const {
    // appId,
    // userUuid,
    // userName,
    // roomUuid,
    // userRole,
    // roomType,
    // roomName,
    // pretest = false,
    // rtmUid,
    // rtmToken,
    // language,
    // translateLanguage = 'auto',
    // startTime,
    // duration,
    // courseWareList = [],
    // personalCourseWareList = [],
    userUuid,
    userName,
    roomUuid,
    roleType,
    roomType,
    roomName,
    pretest,
    rtmUid,
    rtmToken,
    language,
    startTime,
    duration,
    recordUrl,
    appId,
    userRole,
    translateLanguage
  } = useParams(window.location)

  // const options = paramsObject
  // if(!options) {
  //     document.querySelector("#root1").textContent = "options missing"
  // } else {
  //AgoraEduSDK.setParameters()
  AgoraEduSDK.setParameters(JSON.stringify({
	'edu.apiUrl': `https://api-solutions-dev.bj2.agoralab.co`
  }))
  AgoraEduSDK.config({
      appId,
      cachePath: undefined,
  })
  AgoraEduSDK.launch(
      document.querySelector("#root1"), {
        userUuid,
        userName,
        roomUuid,
        roleType: Number(roleType),
        roomType: Number(roomType),
        roomName,
        pretest: false,
        rtmUid,
        rtmToken,
        language: "zh",
        startTime,
        duration,
        recordUrl,
        appId,
        userRole,
        translateLanguage: "zh",
        courseWareList: [],
        listener: (evt, args) => {
          console.log("evt", evt, args);
        }
      }
  ).then(() => {
    console.log('start launch')
  })
  // }
  </script>
</body>

</html>
